//
//  TestWeightPart2.m
//  IWeighMyself
//
//  Created by Francisco Gindre on 8/19/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "TestWeightPart2.h"


@implementation TestWeightPart2

-(void)testWeightInPounds {
	someWeight = [[[Weight alloc]initWithWeightInPounds:[NSNumber numberWithInt:80] date:[NSDate date]] retain];
	STAssertEquals ([[NSNumber numberWithInt:80]floatValue], [someWeight.weightInPounds floatValue],@"weight in pounds not equal %@",someWeight.weightInPounds,nil);
	
}

-(void)testKilosFromPounds {
	someWeight = [[[Weight alloc]initWithWeightInPounds:[NSNumber numberWithInt:80] date:[NSDate date]] retain];
	STAssertEquals([[Weight kilosFromPounds:[NSNumber numberWithInt:80]] floatValue],[someWeight.weightInKilos floatValue],@"converted weight in kilos %@ not equal to weightInKilos %@",[Weight kilosFromPounds:[NSNumber numberWithInt:80]],someWeight.weightInKilos );
	
	STAssertEquals([[Weight kilosFromPounds:[NSNumber numberWithInt:80]] floatValue],(float)36.24,@"converted value %@ not equal to 36.24",[[Weight kilosFromPounds:[NSNumber numberWithInt:80]] floatValue]);
	[someWeight release];
}
-(void)testPoundsFromKilos {
	someWeight = [[[Weight alloc]initWithWeightInKilos:[NSNumber numberWithInt:80] date:[NSDate date]] retain];
	STAssertEquals([[Weight poundsFromKilos:[NSNumber numberWithInt:80]] floatValue],[someWeight.weightInPounds floatValue],@"converted weight in kilos %@ not equal to weightInPoiunds %@",[Weight poundsFromKilos:[NSNumber numberWithInt:80]],someWeight.weightInPounds );
	
	STAssertEquals([[Weight poundsFromKilos:[NSNumber numberWithInt:80]] floatValue],(float)176.32,@"converted value %@ not equal to 176.32",[[Weight poundsFromKilos:[NSNumber numberWithInt:80]] floatValue]);
	[someWeight release];
}

-(void)testGetUnitsInPounds {
	
	someWeight = [[[Weight alloc]initWithWeightInPounds:[NSNumber numberWithFloat:80.4] date:[NSDate date]] retain];
	STAssertEquals(80,[[someWeight getUnitsInPounds] intValue],@"units 80 is not equal to %@",[someWeight getUnitsInPounds],nil);
	
}

-(void)testGetDecimalInPounds {
	someWeight = [[[Weight alloc]initWithWeightInPounds:[NSNumber numberWithFloat:80.4] date:[NSDate date]] retain];
	STAssertEquals((float)80.4,[someWeight.weightInPounds floatValue],@" 80.4 is not equal to weight in pounds %@",someWeight.weightInPounds,nil);
	
	STAssertEquals(4,[[someWeight getDecimalInPounds] intValue],@"units 4 is not equal to %@",[someWeight getDecimalInPounds],nil);
	[someWeight release];
}

-(void)testGetUnitsInKilos {
	someWeight = [[Weight alloc]initWithWeightInKilos:[NSNumber numberWithFloat:80.4] date:[NSDate date]];
	STAssertEquals(80,[someWeight getUnitsInKilos],@"80 units is not equal to %@",[[someWeight getUnitsInKilos] intValue],nil);
	[someWeight release];
	
}


-(void)testGetDecimalInKilos {
	STAssertEquals(40,40,@"",nil);
	someWeight = [[[Weight alloc]initWithWeightInKilos:[NSNumber numberWithFloat:80.4] date:[NSDate date]] retain];
	NSLog(@"decimal %d",[[someWeight getDecimalInKilos] intValue]);
	STAssertEquals(4,[[someWeight getDecimalInKilos] intValue],@"4 decimal is not equal to %@",[someWeight getDecimalInKilos],nil);
	[someWeight release];
}



@end
